<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        navigator
        window.navigator
        // 导航对象---
        console.log(navigator);

        // 用户代理--记录上网的 信息  浏览器--操作系统
        console.log(navigator.userAgent);


        // 获取用户的语言环境 
        // zh-CN 中文
        // en 英语
        console.log(navigator.language);


        if (navigator.userAgent.toLowerCase().indexOf("windows") != -1) {
            console.log("window  pc");
        } else {
            console.log("移动端");
            if (
                navigator.userAgent.toLowerCase().indexOf("iphone") != -1 ||
                navigator.userAgent.toLowerCase().indexOf("ipad") != -1
            ) {
                console.log("ios");
            } else if (navigator.userAgent.toLowerCase().includes("android")) {
                console.log("安卓");
            } else {
                console.log("鸿蒙");
            }
        }

        function isPC() {
            if (navigator.userAgent.toLowerCase().indexOf("windows") != -1) {
                console.log("window  pc");
                return true
            } else {
                console.log("移动端");
                return false

            }
        }

        function isAndroid() {
            if (
                navigator.userAgent.toLowerCase().indexOf("iphone") != -1 ||
                navigator.userAgent.toLowerCase().indexOf("ipad") != -1
            ) {
                console.log("ios");
                return false
            } else if (navigator.userAgent.toLowerCase().includes("android")) {
                console.log("安卓");
                return true
            } else {
                console.log("鸿蒙");
                return false
            }
        }
        function isIOS() {
            if (
                navigator.userAgent.toLowerCase().indexOf("iphone") != -1 ||
                navigator.userAgent.toLowerCase().indexOf("ipad") != -1
            ) {
                console.log("ios");
                return true
            } else if (navigator.userAgent.toLowerCase().includes("android")) {
                console.log("安卓");
                return false
            } else {
                console.log("鸿蒙");
                return false
            }
        }

        function isHm() {
            if (
                navigator.userAgent.toLowerCase().indexOf("iphone") != -1 ||
                navigator.userAgent.toLowerCase().indexOf("ipad") != -1
            ) {
                console.log("ios");
                return false
            } else if (navigator.userAgent.toLowerCase().includes("android")) {
                console.log("安卓");
                return false
            } else {
                console.log("鸿蒙");
                return true
            }
        }
    </script>

</body>

</html>